<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" import="database.DAO, golf.ChatMsg"%>
<%


	DAO dao = DAO.getInstance();
	ChatMsg msg = new ChatMsg();
	msg.setServerNo(Integer.parseInt(session.getAttribute("serverNo").toString()));
	msg.setRoomNo(Integer.parseInt(session.getAttribute("roomNo").toString()));
	
	System.out.println("SERVERNO : " + msg.getServerNo());
	
	msg.setChatCd(request.getParameter("chatCD"));
	if(msg.getChatCd().compareTo("CT001") == 0) {	//방채팅
		//msg.setRoomNo(Integer.parseInt(session.getAttribute("roomNo").toString()));
		//System.out.println("RoomNo : " + msg.getRoomNo());
		//msg.setGuildNo(-1);
		//msg.setRecvName("");
	} else if(msg.getChatCd().compareTo("CT002") == 0) {	//귓속말대화
		//msg.setRoomNo(-1);
		//msg.setGuildNo(-1);
		msg.setRecvName(request.getParameter("toWho").toString());
		System.out.println("whisper : " + msg.getRecvName());
	} else if(msg.getChatCd().compareTo("CT003") == 0) {	//길드대화
		//msg.setRoomNo(-1);
		msg.setGuildNo(Integer.parseInt(session.getAttribute("guildNo").toString()));
		//msg.setRecvName("");
		
		System.out.println("GuildNo : " + msg.getGuildNo());
	}
	msg.setChatCdClassify(new String("CHATT"));
	msg.setChatContent(request.getParameter("chatType"));
	msg.setChatNo(0);
	msg.setSenderNo(Integer.parseInt(session.getAttribute("charNo").toString()));
	System.out.println("SenderNo : " + msg.getSenderNo());
	if( dao.addChatMsg(msg) ){
		System.out.println("채팅 메시지가 DB에 삽입되었습니다.");
	} else {
		System.out.println("채팅 메시지의 DB삽입에 오류가 발생하였습니다.");
	}

%>